#include "qprogressbardialog.h"
#include "ui_qprogressbardialog.h"

QProgressBarDialog::QProgressBarDialog(QWidget *parent) :
    QBaseDialog(parent,Qt::WindowTitleHint | Qt::CustomizeWindowHint),
    ui(new Ui::QProgressBarDialog)
{
    ui->setupUi(this);
}

QProgressBarDialog::~QProgressBarDialog()
{
    delete ui;
}

void QProgressBarDialog::set_value(int value)
{
    ui->bar->setVisible(true);
    if(ui->bar->maximum()<=0)
    {
        ui->bar->setRange(0,8192);
    }
    ui->bar->setValue(value);

    QString str;

    str.sprintf("%0.2f%%",value*100.0/8192);
    setWindowTitle(str);
    ui->text->setText(str);
}

int QProgressBarDialog::exec()
{
    ui->bar->setRange(0,-1);
    ui->bar->setValue(0);

    return QBaseDialog::exec();
}

